﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ZEntity.Data.ORM
{
    /// <summary>
    /// 对象映射基类
    /// </summary>
    public class ORMBase
    {
    }

    /// <summary>
    /// 表属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class BaseAttribute : Attribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tableName">表名</param>
        public BaseAttribute(string name) {
            Name = name;
        }

        private string name;
        /// <summary>
        /// 名称
        /// </summary>
        public string Name {
            get { return name; }
            set { name = value; }
        }

        private string description;
        /// <summary>
        /// 说明
        /// </summary>
        public string Description {
            get { return description; }
            set { description = value; }
        }
    }

    /// <summary>
    /// 表属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
    public class DataTableAttribute : BaseAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tableName">表名</param>
        public DataTableAttribute(string tableName) : base(tableName) {  
        }
    }

    /// <summary>
    /// 主键属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class KeyFieldAttribute : BaseAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tableName">表名</param>
        public KeyFieldAttribute(string name) : base(name) {
        }

        private SqlDbType type;
        /// <summary>
        /// 类型
        /// </summary>
        public SqlDbType Type {
            get { return type; }
            set { type = value; }
        }

        private int length;
        /// <summary>
        /// 长度
        /// </summary>
        public int Length {
            get { return length; }
            set { length = value; }
        }

        private bool nullable;
        /// <summary>
        /// 是否可空
        /// </summary>
        public bool Nullable {
            get { return nullable; }
            set { nullable = value; }
        }
    }

    /// <summary>
    /// 字段属性
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
    public class DataFieldAttribute : BaseAttribute
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="tableName">表名</param>
        public DataFieldAttribute(string name) : base(name){
        }

        private SqlDbType type;
        /// <summary>
        /// 类型
        /// </summary>
        public SqlDbType Type {
            get { return type; }
            set { type = value; }
        }

        private int length;
        /// <summary>
        /// 长度
        /// </summary>
        public int Length {
            get { return length; }
            set { length = value; }
        }

        private bool nullable;
        /// <summary>
        /// 是否可空
        /// </summary>
        public bool Nullable {
            get { return nullable; }
            set { nullable = value; }
        }
    }
}
